package Network;



import DataStructures.Project;
import General.Utilities;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Marshaller;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Manuel
 */
public class Packager {

    private Connector conn;

    public Packager(Connector c) {
        conn = c;
    }

    public String marshall(Project p){

        String data = null;

        try{
         JAXBContext context = JAXBContext.newInstance(Project.class);

        Marshaller m = context.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        File b = new File(p.getProjectInfo().getName()+".xml");
        m.marshal(p, b);
        System.out.println("Start to read from data");
        data = Utilities.readFromFile(p.getProjectInfo().getName()+".xml");
        System.out.println("READ DATA.");
        return data;
        }catch(Exception e){
        e.printStackTrace();}
        return "";
        }
    

}
